package com.liCheng.service.role;

import com.liCheng.dao.role.RoleMapper;
import com.liCheng.entity.Role;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("roleService")
public class RoleServiceImpl implements RoleService {

    @Resource
    private RoleMapper roleMapper;

    public RoleMapper getRoleMapper() {
        return roleMapper;
    }

    public void setRoleMapper(RoleMapper roleMapper) {
        this.roleMapper = roleMapper;
    }

    /**
     * 模糊查询
     * @param role
     * @return
     */
    @Override
    public List<Role> roleList(Role role) {
        try{
            return roleMapper.getRoleList(role);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 添加
     * @param role
     * @return
     */
    @Override
    public int roleAdd(Role role) {
        try{
            return roleMapper.roleAdd(role);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 修改
     * @param role
     * @return
     */
    @Override
    public int roleUpdate(Role role) {
        try{
            return roleMapper.roleUpdate(role);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }

    /**
     * 删除
     * @param role
     * @return
     */
    @Override
    public int roleDel(Role role) {
        try{
            return roleMapper.roleDel(role);
        }catch (Exception e){
            e.printStackTrace();
            throw e;
        }
    }
}
